package utils.test.img;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import lion.dev.image.ImageJ;

/**
 * @author lion
 * @date 2016年9月14日
 */
public class Tx {

	public static void main(String[] args) throws IOException {

		//
		// BufferedImage image = ImageIO.read(new File("D:/d.jpg"));
		// // ImageIO.write(image, "JPEG", new
		// FileOutputStream("D:/driect.jpg"));
		//
		// ImageReader ir = ImageIO.getImageReadersByFormatName("jpeg").next();
		// ir.setInput(ImageIO.createImageInputStream(new File("D:/d.jpg")),
		// true);
		// ImageWriter writer = ImageIO.getImageWriter(ir);
		// IIOMetadata meta = ir.getImageMetadata(0);
		// // writer.setOutput(ImageIO.createImageOutputStream(new
		// // FileOutputStream("D:/direct_with_meta.jpg")));
		// // writer.write(new IIOImage(image, null, meta));
		//
		// ColorModel cm = image.getColorModel();
		// BufferedImage bm = new BufferedImage(cm,
		// cm.createCompatibleWritableRaster(600, 399),
		// cm.isAlphaPremultiplied(), null);
		// Image im = image.getScaledInstance(600, 399, Image.SCALE_SMOOTH);
		//
		// Graphics2D g = bm.createGraphics();
		// g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
		// RenderingHints.VALUE_ANTIALIAS_ON);
		// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
		// RenderingHints.VALUE_INTERPOLATION_BILINEAR);
		// g.drawImage(im, 0, 0, null);
		// g.dispose();
		//
		// float[] data = { -0.05f, -0.05f, -0.05f, -0.05f, 1.2f, 0.0f, 0.1f,
		// -0.05f, -0.05f };
		// Kernel kernel = new Kernel(3, 3, data);
		// ConvolveOp co = new ConvolveOp(kernel, ConvolveOp.EDGE_ZERO_FILL,
		// null);
		// bm = co.filter(bm, null);
		//
		// writer.setOutput(ImageIO.createImageOutputStream(new
		// FileOutputStream("D:/cm_with_meta_rh_1.jpg")));
		//
		// ImageWriteParam param = writer.getDefaultWriteParam();
		// param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
		// param.setCompressionQuality(1);
		//
		// writer.write(new IIOImage(bm, null, meta));

		// ImageJ imageJ = new ImageJ(new File("D:/d.jpg"));
		// imageJ.resizeWidth(600).write(new FileOutputStream("D:/aaaccc.jpg"));
		// ImageJ imageJ = new ImageJ(new File("D:/xx.gif"));
		// imageJ.resizeWidth(200).write(new FileOutputStream("D:/xxx1.gif"));
		// ImageJ imageJ = new ImageJ(new File("D:/02.png"));
		// imageJ.resizeWidth(200).write(new FileOutputStream("D:/22222.png"));
		// ImageJ imageJ = new ImageJ(new File("D:/33.bmp"));
		// imageJ.resizeWidth(500).write(new FileOutputStream("D:/333.bmp"));

		ImageJ imageJ = new ImageJ(new File("D:/mmm.gif"));
		imageJ.resizeWidth(300).write(new FileOutputStream("D:/m11.gif"));
	}

}
